const util = require('../../../../utils/util.js');
const api = require('../../../../config/api.js');
const app = getApp();
Page({
  data: {
    //控制介绍全文显示
    showqanwen: false,
    //非本人访问主页时 顶部功能键
    topdddShow: false,
    //日记页数
    daypageNum: 1,
    //专题页数
    szpageNum: 1,
    //兴趣圈子页数
    interestPageNum: 1,
    //点赞触发开关
    opendz: true,
    //日记更多功能面板
    funShow: false,
    //打开更多面板的Index
    popIndex: '',
    //删除提示面板控制
    delMb: false,
    //获取手机型号
    shouji: null,
    //控制手帐卡片的选择
    nowkapian: 0,
    //贴纸蒙层控制
    tiezhishow: false,
    //贴纸类目选择
    tiezhileimu: 1,
    //控制标签,圈子,趣视,词条面板开关
    shrinkShow: 1,
    //控制日记排序
    pxShow: 0,
    //控制日记显示方式
    xsShow: 1,
    //控制修改窗口显示
    updateShow: false,
    //控制切换皮肤显示
    showhuanfu: false,
    //接收修改后的书名
    newbookname: '',
    //获取用户信息
    logininfo: {},
    //获取用户id
    openid: '',
    //获取访问用户id
    getopenid: '',
    //接收访问用户的昵称
    nickName: '',
    //皮肤
    bookcolor: '',
    //是否显示选项卡
    visible: false,
    visible2: false,
    visible3: false,
    //接收点击的参数
    dIndex: null,
    //选项卡数据
    butText: [{name: '取消'},{name: '确认',color: '#fe7f0c'}],
    actions: [{ name: '置顶展示' }, { name: '退出圈子' }],
    actions2: [{ name: '置顶展示' }, { name: '退出专辑' }],
    actions3: [{ name: '置顶展示' }, { name: '退出星球' }],
    //对话栏1
    duihua1: false,
    //对话栏2
    duihua2: false,
    //徽章集合
    huizhangarr: [{ 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/xigua.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '连续打卡', 'label3': '评选精选', 'label4': '收获点赞', 'label1score': '7', 'label2score': '7', 'label3score': '0', 'label4score': '2' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/baicai.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '答题用时', 'label3': '点评平均分', 'label4': '答题正确率', 'label1score': '4', 'label2score': '1分20秒', 'label3score': '8', 'label4score': '95%' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/donggua.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '连续打卡', 'label3': '评选精选', 'label4': '收获点赞', 'label1score': '7', 'label2score': '7', 'label3score': '0', 'label4score': '2' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/fanqie.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '答题用时', 'label3': '点评平均分', 'label4': '答题正确率', 'label1score': '4', 'label2score': '1分20秒', 'label3score': '8', 'label4score': '95%' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/huanggua.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '连续打卡', 'label3': '评选精选', 'label4': '收获点赞', 'label1score': '7', 'label2score': '7', 'label3score': '0', 'label4score': '2' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/lajiao.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '答题用时', 'label3': '点评平均分', 'label4': '答题正确率', 'label1score': '4', 'label2score': '1分20秒', 'label3score': '8', 'label4score': '95%' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/luobo.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '连续打卡', 'label3': '评选精选', 'label4': '收获点赞', 'label1score': '7', 'label2score': '7', 'label3score': '0', 'label4score': '2' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/qiezi.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '答题用时', 'label3': '点评平均分', 'label4': '答题正确率', 'label1score': '4', 'label2score': '1分20秒', 'label3score': '8', 'label4score': '95%' }, { 'zhongzi': 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/yumi.png', 'qname': '演示数据', 'label1': '打卡天数', 'label2': '连续打卡', 'label3': '评选精选', 'label4': '收获点赞', 'label1score': '7', 'label2score': '7', 'label3score': '0', 'label4score': '2' },],
    huizhangcolors: ['#fb6345', '#ffa245', '#ffc845', '#2ecc53', '#4fe6e8', '#619ef2', '#f7bdd0'],
    //词条数组
    citiaoarr: [{ "id": "1", "top": true, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/1.png', 'name': '测试数据', 'quanzhu': true, 'lable': '娱乐·萌宠奇趣', 'quanshu': '4' }, { "id": "2", "top": true, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/2.png', 'name': '测试数据', 'quanzhu': false, 'lable': '运动·体育赛事', 'quanshu': '7' }, { "id": "3", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/3.png', 'name': '测试数据', 'quanzhu': true, 'lable': '运动·极限运动', 'quanshu': '2' }, { "id": "4", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/1.png', 'name': '测试数据', 'quanzhu': false, 'lable': '公益·社会援助', 'quanshu': '2' }, { "id": "5", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/2.png', 'name': '测试数据', 'quanzhu': false, 'lable': '其他·每天的日常生活', 'quanshu': '2' }],
    //趣视星球数组
    qushiarr: [{ "id": "1", "top": true, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/1.png', 'name': '测试数据', 'quanzhu': true, 'lable': '才艺·音乐/乐器', 'canyushu': '26' }, { "id": "2", "top": true, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/2.png', 'name': '测试数据', 'quanzhu': false, 'lable': '旅游·摄影游', 'canyushu': '21' }, { "id": "3", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/3.png', 'name': '测试数据', 'quanzhu': true, 'lable': '极限游戏', 'canyushu': '5' }, { "id": "4", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/1.png', 'name': '测试数据', 'quanzhu': false, 'lable': '休闲家具·主题设计', 'canyushu': '66' }, { "id": "5", "top": false, 'poster': 'https://image.xingqubaike.com:8443/minicard/ucenter/personcenter/background/scene/2.png', 'name': '测试数据', 'quanzhu': false, 'lable': '其他·每天的日常生活', 'canyushu': '12' }],
    kapianarr: [{ "id": "1", "url": "https://image.xingqubaike.com:8443/minicard/grade/kp.png", 'unread': true }, { "id": "2", "url": "https://image.xingqubaike.com:8443/minicard/grade/kp.png", 'unread': false }, { "id": "3", "url": "https://image.xingqubaike.com:8443/minicard/grade/kp.png", 'unread': true }, { "id": "4", "url": "https://image.xingqubaike.com:8443/minicard/grade/kp.png", 'unread': false }, { "id": "5", "url": "https://image.xingqubaike.com:8443/minicard/grade/kp.png", 'unread': false }],
    //卡通贴纸
    kttiezhiarr: ['https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png', 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png', 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png', 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png', 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png', 'https://image.xingqubaike.com:8443/minicard/ucenter/personhome/homesetup/tiezhizhu.png'],
    //使用中的贴纸
    usetiezhis: []
  },
  //加载用户
  onLoad: function (option) {
    var _this = this
    _this.setData({
      logininfo: app.globalData.logininfo,
      openid : app.globalData.logininfo.openid
    });
    //判断是不是用户本人访问
    if (option.openid != null && option.openid!=''){
      _this.setData({
        getopenid: option.openid
      })
    }else{
      _this.setData({
        getopenid : app.globalData.logininfo.openid
      })
    }
    console.log(_this.data.getopenid);
  },
  //加载数据
  onReady: function(){
    var _this = this
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        //添加访问
        if (openid != getopenid) {
          var data = {};
          data.openid = openid
          data.access_token = res.access_token;
          data.param = JSON.stringify({ "openid": getopenid })
          console.log(data)
          util.post(api.SaveUserAccessInfo, data).then(function (res) {
            if (res.code == 200) {
              console.log("添加成功"+res)
            }
          });
        }
        var data = {};
        data.openid = getopenid;
        data.access_token = res.access_token;
        //获取用户信息
        util.post(api.GetUserInfoByHomepage, data).then(function (res) {
          if (res.code == 200) {
            _this.setData({
              userData: res.result.json,
            })
            _this.setData({
              nickName: _this.data.userData.nickname
            })
            _this.getAstro();
            console.log(_this.data.userData)
          }
        });
        //获取用户地址信息
        data.openid = getopenid;
        data.access_token = res.access_token;
        util.post(api.GetBasAddressByUser, data).then(function (res) {
          if (res.code == 200) {
            if (res.result.list.length > 0) {
              _this.setData({
                addrarr: res.result.list
              })
              console.log(res.result.list)
            }
          }
        });
        //获取用户资料
        util.post(api.GetHomeInfo, data).then(function (res) {
          if (res.code == 200) {
            _this.setData({
              userData2: res.result.entity
            })
          }
        });
        //加载我是谁类型标签
        util.post(api.GetUserWhoInfo, data).then(function (res) {
          if (res.code == 200) {
            var sel = res.result.list
            _this.setData({
              tagarr: sel
            })
          }
        });
        //加载兴趣标签
        util.post(api.GetUserCatalog, data).then(function (res) {
          if (res.code == 200) {
            var transit = res.result.json.interestTagList
            _this.setData({
              interstarr: transit
            })
          }
        });
        data.pageNum = 1
        data.pageSize = 5
        //获取访问记录
        util.post(api.GetUserAccessInfo, data).then(function (res) {
          if (res.code == 200) {
            _this.setData({
              lookMeSum: res.result.entity,
              lookMeArr: res.result.list
            })
          }
        });
        //获取日记
        var data = {}
        data.openid = openid;
        data.selectOpenid = getopenid;
        data.access_token = res.access_token;
        data.pageNum = 1
        data.pageSize = 10
        data.orderby = _this.data.pxShow
        util.post(api.GetDiaryByUser, data).then(function (res) {
          if (res.code == 200) {
            _this.setData({
              diaryList: res.result.list,
              daypageNum: 1
            })
            console.log(_this.data.diaryList)
          }
        });
      });
    }
    //获取书本颜色
    var data = {};
    data.type = 1;
    util.post(api.GetBasBackgroundColor, data).then(function (res) {
      if (res.code == 200) {
        _this.setData({
          colors: res.result.list
        })
      }
    });
    //获取手机系统
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          shouji: res.platform
        })
      },
    })
  },
  //判断星座
  getAstro:function (){
    var _this = this
    var birthday = _this.data.userData.birthday
    var month = birthday.substring(5,7)
    var day = birthday.substring(8)
    console.log(month)
    console.log(day)
    var s = "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手";
    var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
    var xz = s.substr(month * 2 - (day < arr[month - 1] ? 2 : 0), 2)+"座";
    _this.setData({
      xingzuo: xz
    })
  },
  //获取用户默认位置
  getDefaultAddr: function(){
    var _this = this
    var arr = _this.data.addrarr
  },
  //拉伸顶部刷新
  onPullDownRefresh: function () {
    this.onReady();
    wx.stopPullDownRefresh();
  },
  //拉伸底部加载
  onReachBottom: function () {
    var _this = this;
    var getopenid = _this.data.getopenid;
    var openid = app.globalData.logininfo.openid;
    var sel = _this.data.xsShow;
    var data = {};
    if (sel == 1) {
      var daypg = parseInt(_this.data.daypageNum + 1);
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取日记
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = daypg
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryByUser, data).then(function (res) {
            if (res.code == 200) {
              var detailsList = res.result.list;
              var arr = _this.data.diaryList;
              for (var i = 0; i < detailsList.length; i++) {
                arr.push(detailsList[i])
              }
              _this.setData({
                diaryList: arr,
                daypageNum: daypg
              })
              console.log(_this.data.diaryList)
            }
          });
        });
      }
    }
    if (sel == 2) {
      var szpg = parseInt(_this.data.szpageNum + 1);
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取专题手帐
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = szpg
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryHandAccountByUser, data).then(function (res) {
            if (res.code == 200) {
              var detailsList = res.result.list;
              var arr = _this.data.handDiaryList;
              for (var i = 0; i < detailsList.length; i++) {
                arr.push(detailsList[i])
              }
              _this.setData({
                handDiaryList: arr,
                szpageNum: szpg
              })
              console.log(_this.data.handDiaryList)
            }
          });
        });
      }
    }
    wx.stopPullDownRefresh();
  },
  //设置分享
  onShareAppMessage() {
    return {
      title: '最具人气的手帐社区',
      desc: '',
      path: '/ucenter/pages/ucenter/personhome/personhome'
    }
  },
  //获取页面监听
  onPageScroll: function (e) {
    var name = this.data.nickName;
    var scrollTop = parseInt(e.scrollTop);
    this.setData({
      scroll_Top: scrollTop
    })
    var query = wx.createSelectorQuery();
    query.select('.poster').boundingClientRect(function (rect) {
      var wz = parseInt(rect.height);
      if (scrollTop >= wz) {
        // 页面标签设为用户名
        wx.setNavigationBarTitle({
          title: name,
        })
      } else {
        // 页面标签设为用户名
        wx.setNavigationBarTitle({
          title: '',
        })
      }
    }).exec();
  },
  //标签,圈子,专辑面板控制
  showAdd: function (e) {
    var _this = this
    var select = e.currentTarget.dataset.id
    var olbid = this.data.shrinkShow
    var sys = this.data.shouji
    var getopenid = _this.data.getopenid;
    console.log(getopenid)
    var openid = app.globalData.logininfo.openid;
    console.log(openid)
    if (select != this.data.shrinkShow) {
      this.setData({
        shrinkShow: select
      })
      console.log(this.data.shrinkShow)
    } else {
      this.setData({
        shrinkShow: null
      })
    }
    if (this.data.shrinkShow == 1) {   
      var data = {};
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          data.openid = getopenid;
          data.access_token = res.access_token;
          util.post(api.GetUserCatalog, data).then(function (res) {
            if (res.code == 200) {
              var transit = res.result.json.interestTagList
              _this.setData({
                interstarr: transit
              })
            }
          });
        });
      }
      if (sys != 'ios') {
        //API  安卓端存在异常
      } else {
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label1').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
    if (this.data.shrinkShow == 6) {
      var arr = this.data.huizhangarr;
      console.log(arr)
      var col = this.data.huizhangcolors;
      console.log(col)
      var alength = arr.length;
      var clength = col.length;
      var j = 0
      for (var i = 0; i <= alength - 1; i++) {
        if (j <= clength - 1) {
          console.log(col[j])
          arr[i].color = col[j]
          j++
        } else {
          var j = 0;
          arr[i].color = col[j]
          j++
        }
      }
      this.setData({
        huizhangarr: arr
      })
      console.log(this.data.huizhangarr)
      var scroll = this.data.scroll_Top;
      var query = wx.createSelectorQuery();
      if (sys!='ios'){
        //API  安卓端存在异常
      }else{
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label6').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
    if (this.data.shrinkShow == 2) {
      var _this = this;
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          var data = {};
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = 1;
          data.pageSize = 5;
          util.post(api.Home_ParticipateCircleApiUrl, data).then(function (res2) {
            if (res2.code == 200) {
              var resultList = res2.result.list;
              _this.setData({
                interestJoinList: resultList,
                interestPageNum: 1
              })
              console.log(resultList)
            }
          })
        });
      }
      if (sys != 'ios') {
        //API  安卓端存在异常
      } else {
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label2').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
    if (this.data.shrinkShow == 3) {
      if (sys != 'ios') {
        //API  安卓端存在异常
      } else {
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label3').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
    if (this.data.shrinkShow == 4) {
      if (sys != 'ios') {
        //API  安卓端存在异常
      } else {
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label4').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
    if (this.data.shrinkShow == 5) {
      if (sys != 'ios') {
        //API  安卓端存在异常
      } else {
        var scroll = this.data.scroll_Top;
        var query = wx.createSelectorQuery();
        query.select('#label5').boundingClientRect(function (rect) {
          console.log(rect)
          var wz = parseInt(rect.top);
          if (wx.pageScrollTo) {
            wx.pageScrollTo({
              scrollTop: parseInt(scroll + wz),
              duration: 300
            })
          }
        }).exec();
      }
    }
  },
  //控制日记排序
  selectpx: function () {
    if (this.data.pxShow==1) {
      this.setData({
        pxShow: 0
      })
    } else {
      this.setData({
        pxShow: 1
      })
    }
    var _this = this
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    var sel = this.data.xsShow;
    if (sel == 1) {
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取日记
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = 1
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryByUser, data).then(function (res) {
            if (res.code == 200) {
              _this.setData({
                diaryList: res.result.list,
                daypageNum: 1
              })
              console.log(_this.data.diaryList)
            }
          });
        });
      }
    }
    if (sel == 2) {
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取日记手帐
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = 1
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryHandAccountByUser, data).then(function (res) {
            if (res.code == 200) {
              _this.setData({
                handDiaryList: res.result.list,
                szpageNum: 1
              })
              console.log(_this.data.handDiaryList)
            }
          });
        });
      }
    }
  },
  //控制日记显示方式
  selectxs: function (e) {
    var sel = e.currentTarget.dataset.id
    var show = this.data.xsShow;
    var _this = this
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    this.setData({
      xsShow: sel
    })
    if(sel==1){
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取日记
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = 1
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryByUser, data).then(function (res) {
            if (res.code == 200) {
              _this.setData({
                diaryList: res.result.list,
                daypageNum: 1
              })
              console.log(_this.data.diaryList)
            }
          });
        });
      }
    }
    if (sel==2){
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          //获取日记手帐
          var data = {}
          data.openid = openid;
          data.selectOpenid = getopenid;
          data.access_token = res.access_token;
          data.pageNum = 1
          data.pageSize = 10
          data.orderby = _this.data.pxShow
          util.post(api.GetDiaryHandAccountByUser, data).then(function (res) {
            if (res.code == 200) {
              _this.setData({
                handDiaryList: res.result.list,
                szpageNum: 1
              })
              console.log(_this.data.handDiaryList)
            }
          });
        });
      }
    }
  },
  //开启切换皮肤
  showhpf: function () {
    this.setData({
      showhuanfu: true
    })
  },
  //关闭切换皮肤
  closehpf: function () {
    this.setData({
      showhuanfu: false
    })
  },
  //切换书皮颜色
  huanpifu: function (e) {
    var aIndex = e.currentTarget.dataset.id
    var col = this.data.colors[aIndex].value
    var _this = this
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    var userdata = _this.data.userData
    userdata.handAccountBackgroundColor = col
    _this.setData({
      userData: userdata
    })
    console.log(userdata)
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var data = {};
        data.openid = openid;
        data.access_token = res.access_token;
        data.param = JSON.stringify({ "handAccountBackgroundColor": col })
        util.post(api.UpateUserSetup, data).then(function (res) {
          if (res.code == 200) {
            console.log(res)
          }
        });
      });
    }
  },
  //显示修改窗口
  showupdate: function () {
    this.setData({
      updateShow: true
    })
  },
  //修改窗口点击取消还是确认
  handleClick: function({ detail }) {
    const index = detail.index;
    console.log(index)
    if (index === 0) {  
      this.closeupdate();
    } else if (index === 1) {
      this.updatenamesave();
    }
  },
  //关闭修改窗口
  closeupdate: function () {
    this.setData({
      updateShow: false
    })
  },
  //获取修改后的名称
  newName: function (e) {
    var name = e.detail.value.replace(/\s+/g, '')
    console.log(name)
    var length = name.length;
    this.setData({
      newbookname: name
    })
  },
  //修改书名
  updatenamesave: function () {
    var _this = this
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    var bookname = _this.data.newbookname;
    var length = bookname.length;
    var userdata = _this.data.userData
    if (length != 0) {
      userdata.handAccountName = bookname
      _this.setData({
        userData: userdata
      })
      var data = {};
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          data.openid = openid;
          data.param = JSON.stringify({ "handAccountName": bookname });
          data.access_token = res.access_token;
          util.post(api.UpdateWechatloginHandAccountName, data).then(function (res) {
            if (res.code == 200) {
              console.log(res)
            }
          });
        });
      }
    } else {
      wx.showToast({
        title: '基地名称不能为空',
        icon: 'none',
        duration: 2000
      })
    }
    this.setData({
      updateShow: false
    })
  },
  //切换卡片
  select: function (e) {
    console.log(e)
    var sel = e.detail.current;
    console.log(sel)
    this.setData({
      nowkapian: sel
    })
  },
  //赞卡片
  kapianzan: function () {
    var sel = this.data.nowkapian
    var arr = this.data.kapianarr.length
    if (sel == arr) {
      wx: wx.showToast({
        title: '后面没有手帐卡片啦~',
        icon: 'none',
        duration: 2000
      })
    } else {
      console.log(sel)
      this.setData({
        nowkapian: parseInt(sel) + 1
      })
    }
  },
  //开启选项卡
  showxz: function (e) {
    var eIndex = e.currentTarget.dataset.index
    var arr = this.data.interestJoinList
    var xz = this.data.actions
    if (arr[eIndex].circleidIsPlacedtop==1) {
      xz[0].name = '取消置顶展示'
      this.setData({
        actions: xz
      })
    } else {
      xz[0].name = '置顶展示'
      this.setData({
        actions: xz
      })
    }
    this.setData({
      dIndex: eIndex,
      visible: true
    })
  },
  //开启选项卡2
  showxz2: function (e) {
    var eIndex = e.currentTarget.dataset.index
    var arr = this.data.citiaoarr
    var xz = this.data.actions2
    if (arr[eIndex].top) {
      xz[0].name = '取消置顶展示'
      this.setData({
        actions2: xz
      })
    } else {
      xz[0].name = '置顶展示'
      this.setData({
        actions2: xz
      })
    }
    this.setData({
      dIndex: eIndex,
      visible2: true
    })
  },
  //开启选项卡3
  showxz3: function (e) {
    var eIndex = e.currentTarget.dataset.index
    var arr = this.data.qushiarr
    var xz = this.data.actions3
    if (arr[eIndex].top) {
      xz[0].name = '取消置顶展示'
      this.setData({
        actions3: xz
      })
    } else {
      xz[0].name = '置顶展示'
      this.setData({
        actions3: xz
      })
    }
    this.setData({
      dIndex: eIndex,
      visible3: true
    })
  },
  //关闭选项卡
  closexz: function () {
    this.setData({
      dIndex: null,
      visible: false,
      visible2: false,
      visible3: false,
    })
  },
  //点击选项卡
  selectxz: function (e) {
    var eIndex = e.detail.index
    var qIndex = this.data.dIndex
    var arr = this.data.interestJoinList
    var _this = this;
    var openid = app.globalData.logininfo.openid;
    var getopenid = _this.data.getopenid;
    if (eIndex == 0) {
      if (openid != null && openid != "") {
        util.post(api.fetchToken()).then(function (res) {
          if (res.access_token != '') {
            return Promise.resolve({
              access_token: res.access_token
            });
          }
        }).then(function (res) {
          var id = arr[qIndex].id;
          var data = {};
          data.openid = openid;
          data.access_token = res.access_token;
          data.id = id;
          util.post(api.Home_UpdateCircleidIsPlacedtopApiUrl, data).then(function (res) {
            if (res.code == 200) {
              data.selectOpenid = getopenid;
              data.pageNum = 1;
              data.pageSize = 5;
              util.post(api.Home_ParticipateCircleApiUrl, data).then(function (res2) {
                if (res2.code == 200) {
                  var resultList = res2.result.list;
                  _this.setData({
                    interestJoinList: resultList,
                    interestPageNum:1,
                    visible: false
                  })
                }
              })
            }
          })
        })
      }
    }
    if(eIndex==1){
      if (arr[qIndex].indentityType!=1){
        _this.setData({
          visible: false,
          duihua2: true
        })
      }else{
        _this.setData({
          visible: false,
          duihua1: true
        })
      }
    }
  
  },
  //点击选项卡2
  selectxz2: function (e) {
    var eIndex = e.detail.index
    var qIndex = this.data.dIndex
    console.log(qIndex)
    var arr = this.data.citiaoarr
    if (eIndex == 0) {
      if (arr[qIndex].top) {
        arr[qIndex].top = false
        this.setData({
          citiaoarr: arr,
          dIndex: null,
          visible2: false
        })
      } else {
        arr[qIndex].top = true
        this.setData({
          citiaoarr: arr,
          dIndex: null,
          visible2: false
        })
        wx: wx.showToast({
          title: '置顶成功',
          icon: 'success',
          duration: 1500
        })
      }
    }
  },
  //点击选项卡3
  selectxz3: function (e) {
    var eIndex = e.detail.index
    var qIndex = this.data.dIndex
    console.log(qIndex)
    var arr = this.data.qushiarr
    if (eIndex == 0) {
      if (arr[qIndex].top) {
        arr[qIndex].top = false
        this.setData({
          qushiarr: arr,
          dIndex: null,
          visible3: false
        })
      } else {
        arr[qIndex].top = true
        this.setData({
          qushiarr: arr,
          dIndex: null,
          visible3: false
        })
        wx: wx.showToast({
          title: '置顶成功',
          icon: 'success',
          duration: 1500
        })
      }
    }
  },
  // 关闭对话栏
  closeduihua: function () {
    this.setData({
      duihua1: false,
      duihua2: false,
      dIndex: null,
      delMb: false,
      popIndex: null
    })
  },
  //对话栏确认
  quitquanzi: function () {
    var tIndex = this.data.dIndex
    console.log(tIndex)
    var arr = this.data.interestJoinList
    var _this = this;
    var openid = app.globalData.logininfo.openid;
    var getopenid = _this.data.getopenid;
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var id = arr[tIndex].id;
        var data = {};
        data.openid = openid;
        data.access_token = res.access_token;
        data.id = id;
        util.post(api.Home_ExitCircleApiUrl, data).then(function (res) {
          if (res.code == 200) {
            arr.splice(tIndex,1)
            _this.setData({
              interestJoinList: arr,
            })
            _this.closeduihua();
            wx: wx.showToast({
              title: '已退出圈子',
              icon: 'success',
              duration: 1500
            })
          }
        })
      })
    }
  },
  /**
   * 进入圈子详情页面
   */
  navigateToCircleInfo: function (e) {
    var _this = this;
    var circleid = e.currentTarget.dataset.circleid;
    var openid = app.globalData.logininfo.openid;
    var getopenid = _this.data.getopenid;
    var data = {};
    data.circleid = circleid;
    if (openid != null && openid != "") {
      // 已登录
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        data.openid = openid;
        data.access_token = res.access_token;
        _this.userIsCircleJoinQuery(api.Home_UserIsCircleJoinApiUrl, data);
      })
    } else {
      _this.userIsCircleJoinQuery(api.Home_UserIsCircleJoinUrl, data);
    }
  },
  /**
   * 校验用户是否为已加入的圈子：请求
   */
  userIsCircleJoinQuery: function (url, data) {
    var _this = this;
    util.post(url, data).then(function (res) {
      var userIsCircleJoin = false;
      if (res.code == 200) {
        userIsCircleJoin = res.result.userIsCircleJoin;
      }
      console.log(userIsCircleJoin)
      if (userIsCircleJoin) {
        // 已加入
        wx.navigateTo({
          url: '../personcenter/editdetails/circleinteraction/circleinteraction?circleid=' + data.circleid,
        })
      } else {
        // 未加入
        wx.navigateTo({
          url: '../personcenter/editdetails/circledetails/circledetails?circleid=' + data.circleid,
        })
      }
    });
  },
  //跳转兴趣圈
  toxingququang: function(){
    wx.switchTab({
      url: '/pages/interest/interest'
    });
  },
  //新建圈子
  doPublish: function (event) {
    wx.navigateTo({
      url: '../personcenter/publish/publish',
    })
  },
  //跳转设置
  gotoset: function () {
    wx.navigateTo({
      url: '../personinfo/personinfo',
    })
  },
  //跳转隐私设置
  gotoYinse: function () {
    wx.navigateTo({
      url: '../personinfo/homesetup/yinsi/yinsi',
    })
  },
  //跳转关注
  gotoattention: function () {
    wx.navigateTo({
      url: 'attention/attention?openid=' + this.data.getopenid,
    })
  },
  //跳转粉丝
  gotofans: function () {
    wx.navigateTo({
      url: 'fans/fans?openid=' + this.data.getopenid,
    })
  },
  //跳转谁看过我
  gotolookme: function () {
    wx.navigateTo({
      url: 'lookme/lookme?openid=' + this.data.getopenid,
    })
  },
  //跳转兴趣标签
  gotointerest: function () {
    wx.navigateTo({
      url: '../personinfo/homesetup/interesttag/interesttag',
    })
  },
  //跳转我的收藏
  gotocollect: function () {
    wx.navigateTo({
      url: 'collect/collect?openid=' + this.data.getopenid,
    })
  },
  //跳转行程日历
  gotoJourney: function () {
    wx.navigateTo({
      url: '/grade/pages/grade/journey/journey?openid=' + this.data.getopenid,
    })
  },
  //进入手帐卡片评论
  gotopinglun: function () {
    var kIndex = this.data.nowkapian
    console.log(kIndex)
    var arr = this.data.kapianarr
    var kId = arr[kIndex].id
    console.log("id" + kId)
    if (arr[kIndex].unread) {
      arr[kIndex].unread = false
      this.setData({
        kapianarr: arr
      })
    }
    wx.navigateTo({
      url: 'discuss/discuss',
    })
  },
  //打开贴纸功能
  opentiezhi: function () {
    if (this.data.tiezhishow) {
      this.setData({
        tiezhishow: false
      })
    } else {
      this.setData({
        tiezhishow: true
      })
    }
  },
  //选择贴纸类型
  selectleixing: function (e) {
    var sIndex = e.currentTarget.dataset.index
    this.setData({
      tiezhileimu: sIndex
    })
  },
  openqw: function(){
    if(this.data.showqanwen){
    this.setData({
      showqanwen: false
    })
    }else{
      this.setData({
        showqanwen: true
      })
    }
  },
  //选择贴纸贴纸
  kttiezhi: function (e) {
    this.setData({
      tiezhishow: false
    })
    var sIndex = e.currentTarget.dataset.index
    console.log(sIndex)
    var org = this.data.nowkapian
    var tizhi = this.data.kttiezhiarr
    var use = this.data.usetiezhis
    use.push({ 'org': org, 'url': tizhi[sIndex], 'x': '92', 'y': '183', 'tiezhibj': true })
    console.log(use)
    this.setData({
      usetiezhis: use
    })
  },
  //移动贴纸
  movabletiezhi: function (e) {
    console.log(e)
    var mIndex = e.currentTarget.dataset.index;
    var x = e.detail.x;
    var y = e.detail.y;
    var arr = this.data.usetiezhis
    if (y > 310) {
      y = 310
    }
    arr[mIndex].x = x
    arr[mIndex].y = y
    this.setData({
      usetiezhis: arr
    })
  },
  //点击贴纸
  openbj: function (e) {
    var cIndex = e.currentTarget.dataset.index;
    var arr = this.data.usetiezhis
    arr[cIndex].tiezhibj = true
    this.setData({
      usetiezhis: arr
    })
  },
  //手指离开
  closebj: function (e) {
    var cIndex = e.currentTarget.dataset.index;
    var arr = this.data.usetiezhis
    arr[cIndex].tiezhibj = false
    this.setData({
      usetiezhis: arr
    })
  },
  //删除贴纸
  closetiezhi: function (e) {
    var cIndex = e.currentTarget.dataset.index;
    console.log(cIndex)
    var arr = this.data.usetiezhis
    arr.splice(cIndex, 1);
    this.setData({
      usetiezhis: arr
    })
    console.log(arr)
  },
  //选择贴纸
  xztiezhi: function (e) {
    var xIndex = e.currentTarget.dataset.index;
    var arr = this.data.usetiezhis
    console.log(xIndex)
  },
  //点击地址
  wxGetLocation: function (e) {
    var name = e.currentTarget.dataset.name;
    var address = e.currentTarget.dataset.address;
    var latitude = e.currentTarget.dataset.latitude;
    var longitude = e.currentTarget.dataset.longitude;
    wx.openLocation({
      latitude: latitude,//要去的纬度-地址
      longitude: longitude,//要去的经度-地址
      name: name,
      address: address
    })
  },
  //看公众号文章
  navigateToWebView: function (e) {
    var ip = e.currentTarget.dataset.ip;
    var text = e.currentTarget.dataset.text;
    var type = e.currentTarget.dataset.type;
    if (type == 1) {
      wx.navigateTo({
        url: '../../../../pages/home/webView/webView?src=' + text,
      })
    } else {
      wx.downloadFile({
        url: ip + text,
        success: function (res) {
          var filePath = res.tempFilePath;
          wx.openDocument({
            filePath: filePath,
            success: function (res) {
            }
          })
        }
      })
    }
  },
  /**
  * 跳转到视频播放页面
  */
  navigateToVideo: function (e) {
    var _this = this;
    var index = e.currentTarget.dataset.index;
    var yindex = e.currentTarget.dataset.yindex;
    var diaryarr = _this.data.diaryList[index];
    var video = diaryarr.imageVideoList[yindex];
    var diaryid = diaryarr.ordDiary.id;
    var src = video.ip + video.url;
    wx.navigateTo({
      url: "../../../../pages/home/video/video?state=1&type=2&id=" + diaryid + "&src=" + src
    })
  },
  /**
     * 预览图片：日记
     */
  previewImage: function (e) {
    var _this = this;
    var index = e.currentTarget.dataset.index;
    var yindex = e.currentTarget.dataset.yindex;
    var diaryarr = _this.data.diaryList[index];
    var imageList = diaryarr.imageVideoList;
    var urls = [];
    var current = diaryarr.imageVideoList[yindex].ip + diaryarr.imageVideoList[yindex].url;
    for (var i = 0; i < imageList.length; i++) {
      if (imageList[i].imageVideoType == "1") {
        urls.push(imageList[i].ip + imageList[i].url);
      }
    }
    wx.previewImage({
      current: current, // 当前显示图片的http链接
      urls: urls // 需要预览的图片http链接列表
    })
  },
  /**
 * 添加或删除日记能量点赞
 */
  saveOrDeleteOrdDiaryGivelike: function (e) {
    var _this = this;
    var openid = _this.data.openid
    var getopenid = _this.data.getopenid;
    var index = e.currentTarget.dataset.index;
    var diaryGivelikeid = e.currentTarget.dataset.givelikeid;
    _this.setData({
      opendz: false
    })
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var data = {};
        data.openid = openid;
        data.access_token = res.access_token;
        data.diaryid = _this.data.diaryList[index].ordDiary.id;
        data.circleid = _this.data.diaryList[index].ordDiary.circleid;
        data.diaryGivelikeid = diaryGivelikeid;
        util.post(api.Home_SaveOrDeleteOrdDiaryGivelikeApiUrl, data).then(function (res) {
          if (res.code == 200) {
            var arr = _this.data.diaryList
            if (diaryGivelikeid==null){
              if (arr[index].countDiaryGivelike==0){
                arr[index].countDiaryGivelike = 1
              }else{
                parseInt(arr[index].countDiaryGivelike += 1)
              }
              arr[index].diaryGivelike= {"id":999999};
              _this.setData({
                diaryList: arr
              })
            }else{
              parseInt(arr[index].countDiaryGivelike -= 1)
              arr[index].diaryGivelike= null
              _this.setData({
                diaryList: arr
              })
            }
            setTimeout(function () {
              _this.setData({
                opendz: true
              })
            }, 200)
          }
        })
      })
    }
  },
  /**
   * 播放或暂停动作：日记
   */
  voiceBoFang_diary: function (e) {
    var _this = this;
    var index = e.currentTarget.dataset.index;
    var yindex = e.currentTarget.dataset.yindex;
    var diaryAudioList = _this.data.diaryList[index].diaryAudioList[yindex];
    var boFangImage = diaryAudioList.boFangImage;
    var ip = diaryAudioList.ip;
    var name = diaryAudioList.name;
    var currentTime = diaryAudioList.currentTime;
    var audiourl = diaryAudioList.url;
    var backgroundAudioManager = wx.getBackgroundAudioManager();//获取全局唯一的背景音频管理器
    if (boFangImage == api.AudioBoFangImage_Name) {
      // 切换至暂停状态
      wx.pauseBackgroundAudio();//暂停播放音乐
      backgroundAudioManager.pause();//暂停播放音乐
      _this.setData({
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].boFangImage"]: api.AudioNoBoFangImage_Name
      });
    } else {
      // 切换至播放状态
      wx.stopBackgroundAudio();////暂停正在播放音乐
      backgroundAudioManager.startTime = currentTime;//设置音乐开始时间
      backgroundAudioManager.title = name;
      backgroundAudioManager.src = ip + audiourl;
      backgroundAudioManager.play();
      //    背景音频自然播放结束事件
      backgroundAudioManager.onEnded(function () {
        _this.setData({
          ["diaryList[" + index + "].diaryAudioList[" + yindex + "].startDate"]: "00:00",
          ["diaryList[" + index + "].diaryAudioList[" + yindex + "].currentTime"]: 0,
          ["diaryList[" + index + "].diaryAudioList[" + yindex + "].boFangImage"]: api.AudioNoBoFangImage_Name
        });
      })
      //背景音频播放进度更新事件
      backgroundAudioManager.onTimeUpdate(function (callback) {
        var position = parseInt(backgroundAudioManager.currentTime);
        var startDate = util.digitalFormatTime(position);
        _this.setData({
          ["diaryList[" + index + "].diaryAudioList[" + yindex + "].currentTime"]: backgroundAudioManager.currentTime,
          ["diaryList[" + index + "].diaryAudioList[" + yindex + "].startDate"]: startDate
        });
      })
      _this.setData({
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].boFangImage"]: api.AudioBoFangImage_Name
      });
    }
  },
  /**
  * 播放音乐（滚动条事件）：日记
  */
  voiceSlider_diary: function (e) {
    var _this = this;
    var position = e.detail.value;
    var index = e.currentTarget.dataset.index;
    var yindex = e.currentTarget.dataset.yindex;
    var diaryAudioList = _this.data.diaryList[index].diaryAudioList[yindex];
    var boFangImage = diaryAudioList.boFangImage;
    var startDate = util.digitalFormatTime(position);
    var backgroundAudioManager = wx.getBackgroundAudioManager();//获取全局唯一的背景音频管理器
    if (boFangImage == api.AudioBoFangImage_Name) {
      //正在播放状态：不知道为什么，录音的在调用backgroundAudioManager.seek(Math.floor(position))方法无效，所以改成一下这种方式
      _this.setData({
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].currentTime"]: position,
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].boFangImage"]: api.AudioNoBoFangImage_Name
      });
      _this.voiceBoFang_diary(e);
    } else {
      // 未播放状态
      _this.setData({
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].currentTime"]: position,
        ["diaryList[" + index + "].diaryAudioList[" + yindex + "].startDate"]: startDate
      });
    }
  },
  //点击日记更多功能
  gengduofunction: function(e){
    var _this = this;
    var index = e.currentTarget.dataset.index;
    var diaryInfo = _this.data.diaryList[index];
    var id = diaryInfo.ordDiary.id;
    if (diaryInfo.ordDiary.userIsPlacedtop == 1){
      _this.setData({
        jiajingYesNo: "取消日记加精",
      })
    }
    else{
      _this.setData({
        jiajingYesNo: "加精日记",
      })
    }
    _this.setData({
      funShow: true,
      popIndex: index
    })
  },
  //关闭弹出层
  onClose: function(){
    this.setData({
      funShow: false,
      topdddShow: false
    })
  },
  //加精日记
  jiajing: function(){
    var _this = this;
    var index = _this.data.popIndex;
    var openid = _this.data.openid
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var data = {};
        data.openid = openid
        data.diaryid = _this.data.diaryList[index].ordDiary.id;
        data.userIsPlacedtop = _this.data.diaryList[index].ordDiary.userIsPlacedtop != 1 ? 1 : 0;
        data.access_token = res.access_token;
        util.post(api.Home_UpdateDiaryUserIsPlacedtop, data).then(function (res) {
          if (res.code == 200) {
            var arr = _this.data.diaryList
            arr[index].ordDiary.userIsPlacedtop = _this.data.diaryList[index].ordDiary.userIsPlacedtop != 1 ? 1 : 0;
            _this.setData({
              funShow: false,
              diaryList: arr,
              popIndex: null
            })
          }
        });
      })
    }
  },
  //删除操作
  shanchu: function(){
    this.setData({
      delMb : true,
      funShow: false
    })
  },
  //确认删除
  yesDel: function(){
    var _this = this;
    var index = _this.data.popIndex;
    var openid = _this.data.openid
    var list = _this.data.diaryList
    var arr = list[index];
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var data = {};
        data.openid = openid;
        data.access_token = res.access_token;
        data.ordDiaryid = arr.ordDiary.id;
        data.circleid = arr.ordDiary.circleid;
        util.post(api.Home_DeleteDiaryByDiaryIdApiUrl, data).then(function (res) {
          if (res.code == 200) {
            list.splice(index, 1);
            _this.setData({
              diaryList: list
            })
            _this.closeduihua();
          }
        })
      })
    }
  },
  //顶部功能键
  showfunction: function () {
    this.setData({
      topdddShow: true
    })
  },
  //加载更多兴趣圈子
  loadInterestJoinList: function(){
    var _this = this;
    var getopenid = _this.data.getopenid;
    var openid = app.globalData.logininfo.openid;
    if (openid != null && openid != "") {
      util.post(api.fetchToken()).then(function (res) {
        if (res.access_token != '') {
          return Promise.resolve({
            access_token: res.access_token
          });
        }
      }).then(function (res) {
        var num = parseInt(_this.data.interestPageNum+1);
        var data = {};
        data.openid = openid;
        data.selectOpenid = getopenid;
        data.access_token = res.access_token;
        data.pageNum = num;
        data.pageSize = 5;
        util.post(api.Home_ParticipateCircleApiUrl, data).then(function (res2) {
          if (res2.code == 200) {
            var resultList = res2.result.list;
            var arr = _this.data.interestJoinList;
            for (var i = 0; i <= resultList.length - 1; i++) {
              arr.push(resultList[i])
            }
            _this.setData({
              interestJoinList: arr,
              interestPageNum: num
            })
            console.log(resultList)
          }
        })
      });
    }
  },
  /**
   * 跳转身份认证
   */
  gotoAuthentication: function () {
    wx.navigateTo({
      url: '/grade/pages/grade/authentication/authentication',
    })
  },
  /**
   * 跳转晋级VIP
   */
  gotoPromotedVIP: function () {
    wx.navigateTo({
      url: '/grade/pages/grade/promotedVIP/promotedVIP',
    })
  },
})